package cn.lingyueblog.gulimall.product.feign;

import cn.lingyueblog.common.to.SkuReductionTo;
import cn.lingyueblog.common.to.SpuBoundTo;
import cn.lingyueblog.common.utils.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient("gulimall-coupon")
public interface CouponFeignService {
    /**
     * 远程调用梳理
     *
     * 1) 发送(@RequestBody SpuBoundTo spuBoundTo)
     *    @RequestBody将这个对象转为json
     * 2) 找到gulimall-coupon服务，给/coupon/spuBounds/save发送请求
     * 3) 对方服务收到请求，请求体中有json数据
     *    接收(@RequestBody SpuBoundsEntity spuBounds)，将请求体中的json转为spuBoundsEntity
     *
     * 只要json数据模型是兼容的，双方服务无需使用同一个to
     */
    @PostMapping("/coupon/spubounds/save")
    R saveSpuBounds(@RequestBody SpuBoundTo spuBoundTo);

    @PostMapping("/coupon/skufullreduction/saveinfo")
    R saveSkuReduction(@RequestBody SkuReductionTo skuReductionTo);
}
